 import { ADD_CART,PAY,DELETE_GOOD,UPDATE_ORDER,ADD_RESS,CHANGE_ADDRESS} from "./mutation-type"
export default{
    [ADD_CART](state,value){
          state.cartList = value
    },
    [PAY](state,value){
        state.orderList = value
    },
    [DELETE_GOOD](state,value){
       state.cartList = value
    },
    [UPDATE_ORDER](state){
        state.orderListED = state.orderListED.concat(state.orderList)
    },
    [ADD_RESS](state,value){
        state.useAddress.map(item=>{
            if(value.isDefault){
                item.isDefault = false;
            }
        })
        state.useAddress.push(value)
    },
    [CHANGE_ADDRESS](state,value){
        state.useAddress = state.useAddress.map(item=>{
            if(value.isDefault){
                item.isDefault = false;
            }
            return item.id===value.id?value:item
        })
    }
}